package org.jflame.commons.convert;

import org.jflame.commons.util.DateHelper;

import java.util.Calendar;

import org.apache.commons.lang3.time.DateFormatUtils;

/**
 * Calendar格式化
 * 
 * @author charles.zhang
 */
public class CalendarToStringConverter implements Converter<Calendar,String> {

    private String datePattern = null;

    public CalendarToStringConverter() {
        datePattern = DateHelper.YYYY_MM_DD_HH_mm_ss;
    }

    public CalendarToStringConverter(String datePattern) {
        this.datePattern = datePattern;
    }

    @Override
    public String convert(Calendar source) {
        return DateFormatUtils.format(source, datePattern);
    }
}
